package icu.sehnen.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import icu.sehnen.mapper.ProductMapper;
import icu.sehnen.mapper.ProgressMapper;
import icu.sehnen.model.ProductModel;
import icu.sehnen.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    ProductMapper productMapper;
    @Override
    public PageInfo<ProductModel> findAll(Integer pageNum,Integer pageSize,String query) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductModel> productModelList=productMapper.findAll(query);
        PageInfo<ProductModel> pageInfo=new PageInfo(productModelList);
        return pageInfo;

    }

    @Override
    public void delete(Long id) {
        productMapper.delete(id);
    }

    @Override
    public  ProductModel findProductById(Long id) {
        return  productMapper.findProductById(id);
    }

    @Override
    public void update(ProductModel productModel) {
        productMapper.update(productModel);
    }

    @Override
    public void add(ProductModel productModel) {
        productMapper.add(productModel);
    }
}
